class MyPage extends BaseList {
    constructor(orderby, flag, $pagesize, $pagination, listUrl, onLineEditUrl, checkBoxName) {
        super(orderby, flag, $pagesize, $pagination, listUrl, onLineEditUrl, checkBoxName);
    }
    GetFilter(pageIndex) {
        let item = super.GetFilter(pageIndex);
        item['EnterpriseNameFilterValue'] = $.trim($('#EnterpriseNameFilterValue').val()) === '' ? null : $.trim($('#EnterpriseNameFilterValue').val());

        return JSON.stringify(item);
    }
    FetchAll() {
        $("#EnterpriseNameFilterValue").val("");
        this.FetchForPage(1);
    }
    SetTableContent(result) {
        $("#tabData01 tbody").empty();
        $("#tabData02 tbody").empty();
        let content_01 = '';
        let content_02 = '';
        this.numCheckbox = result.length;  // 设置表格中checkbox的数量为表格的行数
        for (let i = 0; i < result.length; i++) {
            let _enterpriseId = result[i].enterpriseId;
            content_01 += '<tr>';
            content_01 += '<td style="padding-left:8px; padding-top:0px; vertical-align:baseline;"><label class="btn" for="R-' + _enterpriseId + '"><input id="R-' + _enterpriseId + '" name="_select_row" type="radio" onclick="_Instance.OnChoice($(this));" value="' + _enterpriseId + '"/><i></i><span></span></label></td>';
            content_01 += '<td>' + formatNullData(result[i].enterpriseNo) + '</td>';
            content_01 += '<td>' + formatNullData(result[i].enterpriseName) + '</td>';
            content_01 += '<td>' + formatNullData(result[i].shortName) + '</td>';
            content_01 += '<td>' + formatNullData(result[i].enterpriseEnName) + '</td>';
            content_01 += '</tr>';

            content_02 += '<tr>';
            content_02 += '<td>' + formatNullData(result[i].address) + '</td>';
            content_02 += '<td>' + formatNullData(result[i].attn) + '</td>';
            content_02 += '<td>' + formatNullData(result[i].attnJob) + '</td>';
            content_02 += '<td>' + formatNullData(result[i].attnMobil) + '</td>';
            content_02 += '<td>' + formatNullData(result[i].fax) + '</td>';
            content_02 += '<td>' + formatNullData(result[i].email) + '</td>';
            content_02 += '<td>' + formatNullData(result[i].openAccountBank) + '</td>';
            content_02 += '<td>' + formatNullData(result[i].bankAccount) + '</td>';
            content_02 += '<td>' + formatNullData(result[i].taxNo) + '</td>';
            content_02 += '<td>' + formatNullData(result[i].enterpriseName) + '</td>';
            content_02 += '<td style="border-right: none;">' + formatNullData(result[i].description) + '</td>';
            content_02 += '</tr>';

            $("#tabData01 tbody").append(content_01);
            $("#tabData02 tbody").append(content_02);
            content_01 = '';
            content_02 = '';
        }
        setTwoTableRowColor("tabData01", "tabData02");

        $(window).resize();                     // 防止因为出现滚动条而造成画面显示问题
        $('#loading').hide();
    }
    // 设置选择结果
    SetChoiceData($self) {
        let $tr1 = $self.parent().parent().parent();
        let _enterpriseName = $.trim($tr1.find('td').eq(3).text());

        return new Array($self.val(), _enterpriseName);
    }
    SortTable(orderBy) {
        this.orderby = orderBy;
        // 得到排序数据
        this.FetchForPage(1);
    }
}

let _Instance = null;

//-----------------------------------------------------------------------------
// 页面初始化
//-----------------------------------------------------------------------------
function onPageReady() {
    let flag = jQuery.url.param("flag") === undefined ? 0 : jQuery.url.param("flag");
    _Instance = new MyPage(null, flag, $("#page-size"), $("abbr.page_indicator_block,#wrapper__navbar"),
            "/master/enterprise/fetchForPage.html",
            "/master/enterprise/online/edit.html",
            "_select_row");

    $("#wrapper__navbar").swPagination({
        link_string: '/?page={page_number}',
        max_page: null,
        paged: function (page) {
            $("abbr.page_indicator_block,#wrapper__navbar").attr("_msh_page", page);
            _Instance.FetchForPage(page);
        }
    });
    _Instance.OnPageLoad();
}

// 画面大小或者位置移动
function onPageResize() {
    let wLeftList = 748; //左边列表固定宽度
    let w = $(window).width();

    $("#divH2").css({left: 0, width: w - 16 - wLeftList});
    $("#divD2").css({left: -1, width: w - 15 - wLeftList});
}
